<?php
/**
 * SocialEngine
 *
 * @category   Application_Core
 * @package    User
 * @copyright  Copyright 2006-2010 Webligo Developments
 * @license    http://www.socialengine.com/license/
 * @version    $Id: index.tpl 9747 2012-07-26 02:08:08Z john $
 * @author     John
 */
?>

<script type="text/javascript">
  en4.core.runonce.add(function(){
    
    <?php if( !$this->renderOne ): ?>
    var anchor = $('user_profile_friends_following').getParent();
    $('user_profile_friends_following_previous').style.display = '<?php echo ( $this->paginator->getCurrentPageNumber() == 1 ? 'none' : '' ) ?>';
    $('user_profile_friends_following_next').style.display = '<?php echo ( $this->paginator->count() == $this->paginator->getCurrentPageNumber() ? 'none' : '' ) ?>';

    $('user_profile_friends_following_previous').removeEvents('click').addEvent('click', function(){
      en4.core.request.send(new Request.HTML({
        url : en4.core.baseUrl + 'widget/index/content_id/' + <?php echo sprintf('%d', $this->identity) ?>,
        data : {
          format : 'html',
          subject : '<?php echo $this->subject->getGuid() ?>',
          page : <?php echo sprintf('%d', $this->paginator->getCurrentPageNumber() - 1) ?>
        }
      }), {
        'element' : anchor
      })
    });

    $('user_profile_friends_following_next').removeEvents('click').addEvent('click', function(){
      en4.core.request.send(new Request.HTML({
        url : en4.core.baseUrl + 'widget/index/content_id/' + <?php echo sprintf('%d', $this->identity) ?>,
        data : {
          format : 'html',
          subject : '<?php echo $this->subject->getGuid() ?>',
          page : <?php echo sprintf('%d', $this->paginator->getCurrentPageNumber() + 1) ?>
        }
      }), {
        'element' : anchor
      })
    });
    <?php endif; ?>

    $$('.friends_lists_menu_input input').each(function(element){
      element.addEvent('blur', function() {
        this.getParents('.drop_down_frame')[0].style.visibility = "hidden";
      });
    });
  });
</script>

<ul class='profile_friends' id="user_profile_friends_following">
  
  <?php foreach ($this->paginator as $story): ?>

    <li id="user_friend_<?php echo $story->story_id ?>">

        <?php echo $this->htmlLink($story->getHref(), $this->itemPhoto($story, 'thumb.icon'), array('class' => 'profile_friends_icon'));?>

      <div class='profile_friends_options'>
      	<?php if($this->followed[$story->story_id]&&$this->own_profile) {
        	echo $this->htmlLink(array('route' => 'story_follow', 'controller' => 'widget', 'action' => 'unfollow', 'story_id' => $story->story_id, 'option_id' => 0), $this->translate('Unfollow'), array(
          'class' => 'buttonlink smoothbox icon_story_delete'));
        } else if(!$this->followed[$story->story_id]&&!$this->own_profile) {
        	echo $this->htmlLink(array('route' => 'story_follow', 'controller' => 'widget', 'action' => 'unfollow', 'story_id' => $story->story_id, 'option_id' => 1), $this->translate('Follow'), array(
          'class' => 'buttonlink smoothbox icon_story_viewall'));
          } else { ?>
          	<i style="font-size: 0.8em;font-weight: 700;"><?php echo $this->translate('Followed');?></i>
         <?php } ?>
      </div>

      <div class='profile_friends_body'>
        <div class='profile_friends_status'>
          <span>
            <?php echo $this->htmlLink($story->getHref(), $this->radcodes()->text()->truncate($story->getTitle(), 28)) ?>
          </span>
            <?php echo $this->partial('index/_meta.tpl', 'story', array('story' => $story))?>
        </div>

      </div>

    </li>

  <?php endforeach ?>
    
</ul>

<div>
  <div id="user_profile_friends_following_previous" class="paginator_previous">
    <?php echo $this->htmlLink('javascript:void(0);', $this->translate('Previous'), array(
      'onclick' => '',
      'class' => 'buttonlink icon_previous'
    )); ?>
  </div>
  <div id="user_profile_friends_following_next" class="paginator_next">
    <?php echo $this->htmlLink('javascript:void(0);', $this->translate('Next'), array(
      'onclick' => '',
      'class' => 'buttonlink_right icon_next'
    )); ?>
  </div>
</div>